import { http } from '@/utils/http'
import { CreateOrderParams, SubmitOrderParams, BuyTypeParams, PayParams } from './type'
// 创建订单
export const fetchCreateOrder = (p: CreateOrderParams) => http.post('/shopapi/order/placeOrder', p)

// 检测商品是否可以购买
export const fetchGoodsCheck = (p: CreateOrderParams) => http.post('/shopapi/order/beforeCheck', p)

// 提交订单
export const fetchSubmitOrder = (p: SubmitOrderParams) => http.post('/shopapi/order/placeOrder', p)

// 支付
export const fetchPay = (p: PayParams) => http.post('/shopapi/pay/prepay', p)

// 支付方式--暂时不用
export const fetchBuyTypeList = (p: BuyTypeParams) => http.get('/shopapi/pay/payway', p)

// 订单列表
export const fetchOrderList = (p: Pagination) => http.get('/shopapi/order/lists', p)

// 取消订单
export const fetchCancelOrder = (id: number) => http.post('/shopapi/order/cancel', { id })

// 获取优惠券列表
export const fetchOrderCouponList = <D>(data: D) => http.post('/shopapi/coupon/orderCoupon', data)

// 订单详情
export const fetchOrderDetail = (id: number) => http.get('/shopapi/order/detail', { id })
